import Vue from 'vue'
import App from './App.vue'
import router from './router'

Vue.config.productionTip = false

// 引入elementUI组件库
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);

// 引入axios
import axios from 'axios'
// import VueAxios from 'vue-axios'
// Vue.use(VueAxios, axios)
// 设置axios的根路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 添加拦截器
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 规定格式最后必须return config
  return config
})
// 把axios挂载到Vue的原型对象上
Vue.prototype.$http = axios
// 导入全局样式表
import './assets/css/global.css'


// 导入第三方插件 TreeTable
import TreeTable from 'vue-table-with-tree-grid'
// 进行全局注册
Vue.component('tree-table', TreeTable)

Vue.filter('dateFormat', function (originVla) {
  const dt = new Date(originVla)
  const y = dt.getFullYear()
  const m = (dt.getMonth() + 1 + '').padStart(2, '0')
  const d = (dt.getDate() + '').padStart(2, '0')
  const hh = (dt.getHours() + '').padStart(2, '0')
  const ss = (dt.getSeconds() + '').padStart(2, '0')

  return `${y}-${m}-${d} ${hh}:${m}:${ss}`
})


// 导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
// require styles 导入富文本编辑器对应的样式
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// 注册为全局可用的组件
Vue.use(VueQuillEditor, /* { default global options } */ )


new Vue({
  router,
  render: h => h(App)
}).$mount('#app')